// JavaScript Document

/**
 * import compontent 
 */
Vsg.importClass(
	[
	]
);


function getStockPerformancePanel() {
	try {
		var store = new Ext.data.JsonStore({
    		// store configs
    		autoLoad : true,
    		//url: ,
    		storeId: 'catePerformanceStore',
    		// reader configs
    		root: 'rows',
			proxy:new Ext.data.ScriptTagProxy({
				url:passParameters.stockCode+"/"+UrlMKey['stk-performance']
			}),
    		idProperty: 'performanceId',  
    		fields: [
				{name:'stockCode'},
				{name:'publishDate'},
				{name:'aIncome', type: 'string'},// 每股收益
				{name:'netAsset', type: 'string'}, // 每股净资产
				{name:'aReserveFund' , type: 'string'}, // 每股公积金
				{name:'undistributedProfit' ,type:'string'} // 未分配利润
			]
		});

		// --- defined the grid panel ---
    	var gridPanel = new Ext.grid.GridPanel({
			id:'stockPerformancePanel',
        	store: store,
			maskDisabled:false,
        	loadMask: true,

        	// grid columns
			colModel:new Ext.grid.ColumnModel([
				{
					header: "公布日期",
					width: 100,
					sortable: true,
					dataIndex: "publishDate"
				},
				{
					header: "每股收益",
					sortable: true, 
					dataIndex: "aIncome"
				},
				{
					header: "每股净资产",
					sortable: false, 
					dataIndex: "netAsset"
				},
				{
					header: "每股公积金",
					sortable: false, 
					dataIndex: "aReserveFund"
				},
				{
					header:'每股未分配利润',
					sortable: false, 
					dataIndex: "undistributedProfit"
				}												
			]),

        	// customize view config
        	viewConfig: {
            	forceFit:true
        	},
			
			tbar:[{
				id:"btnSchedule",
				text : "查看数据",
				iconCls :"time-add",
				xtype:"button",
				handler:Vsg.getDefinedEvent("job-schedule.evt_add")
			}]

    	});
		
		// --- defined and add event ---
		//gridPanel.on("rowclick" , Vsg.getDefinedEvent("CategoryStocksPanel.evt_rowclick"));		
		
		return gridPanel;	
	} catch (e) {
		alert("Get model panel error: "  );
	}	 
}

/** ===============================
 * init ui interface 
 * ================================
 */
function init(){

	try {
		
		// --- set layout content -----
		var $layoutContent = {
			layout:"border",
			items:[
				{
					region:'center',
					margins:{left:5,top:5,right:5,bottom:5},
					layout:'fit',
					border:false,
					items:[getStockPerformancePanel()]
				}
			]
		};

    	new Ext.Viewport( $layoutContent );


	} catch (e) {
		alert('出现系统性错误，请联系管理人员!');
	}
}
// --- run the init method
Vsg.run( init );

